package com.zlz.m3u8download.bean.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: zhulinzhong
 * @Date: 2024/11/29
 */
@Getter
@AllArgsConstructor
public enum DownloadStatus {
    // 下载失败
    DOWNLOAD_FAILED(-1),
    // 待下载
    PENDING_DOWNLOAD(0),
    // 下载成功
    DOWNLOAD_SUCCESS(1),
    // 下载中
    DOWNLOADING(2);

    private final Integer value;

    // 根据整数值获取对应的枚举实例的静态方法
    public static DownloadStatus valueOf(int value) {
        for (DownloadStatus status : DownloadStatus.values()) {
            if (status.getValue() == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid download status value: " + value);
    }
}